{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑会员组</h5>
                </div>
                <div class="ibox-content">
                    <form class="layui-form layui-form-pane" action="{:url('edit_group')}">
                        <input type="hidden" name="id" value="{$group.id}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">组名称：</label>
                            <div class="layui-input-inline">
                                <input id="group_name" type="text" class="layui-input" name="group_name" required="" aria-required="true" value="{$group.group_name}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状&nbsp;态：</label>
                            <div class="layui-input-inline">
                                    <input type="radio" name='status' value="1" {if condition="$group['status'] eq 1 "}checked{/if} title="开启"/>&nbsp;&nbsp;
                                    <input type="radio" name='status' value="0" {if condition="$group['status'] eq 0 "}checked{/if} title="关闭"/>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <button class="btn btn-primary" type="submit" lay-submit lay-filter="edit_group"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    var form = layui.form;
    form.on('submit(edit_group)', function (data) {
        var data = data.field;
        if (!data.group_name) {
            layer.msg('请输入会员组名称', {icon: 2, time: 1500, shade: 0.1}, function (index) {
                layer.close(index);
            });
            return false;
        }
        $.post("{:url('edit_group')}", data, function (result) {
            if (result.code == 1) {
                layer.msg(result.msg, {icon: 6, time: 1500, shade: 0.1}, function (index) {
                    window.location.href = "{:url('member/group')}";
                });
            } else {
                layer.msg(result.msg, {icon: 5, time: 1500, shade: 0.1});
                return false;
            }
        });
        return false;
    });
</script>
</body>
</html>